有关于年的计算```C语`

来源:百度知道 编辑:UC知道 时间:2024/05/24 12:03:34
#include <stdio.h>

int main ()
{
int n,t=0;

scanf("%d",&n);
while(n)
{
t=t*10+n%10;
n/=10;
}
while(t)
{
printf("%d ",t%10);
t/=10;
}
printf("\n");
return 0;
}
输入4个数```要求输出但是输出时每两个间要有空格:
如果输入1904 要输出1 9 0 4
不用函数可以搞定不````
(不用数组,也可以搞定,缺点是最后不能有0,否则程序还需要改进
)
帮我解决这个缺点````最好不要用return 可以不``帮帮我哦```
可以解释最好不过呢`````谢谢

用个数组,就可以了啊

#include <stdio.h>

int main ()
{
int n,a[10]={0},t=0;

scanf("%d",&n);
while(n)
{
a[t++]=n%10;
n/=10;
}
while(t>0)
{
printf("%d ",a[--t]);
}
printf("\n");
return 0;
}